package xkp.lesson.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class JDBCUtils {
    public static Connection openConn() throws ClassNotFoundException, SQLException {
        //连接数据库四要素
        //url 用户名 密码 驱动
        String user = "root";
        String password = "123456";
        String driver = "com.mysql.jdbc.Driver";
        String url = "jdbc:mysql://127.0.0.1:3306/xkp-job?characterEncoding=UTF-8&rewriteBatchedStatements=true";


        //加载数据库驱动
        Class.forName(driver);
        //通过驱动管理器获取与数据库的连接
        Connection connection = DriverManager.getConnection(url,user,password);
        //System.out.println("------------------");
        return  connection;
    }
}
